<%--
  @desc: 应用管理新闻新增
  @author: chenw
  @create: 2014-4-29 下午 15:32
--%>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<style type="text/css">
    .pageFormContent .textInput {
        width: 320px;
    }
    .pageFormContent .fix_p { width: 500px; float: none;}
    .gray {
        color: gray;
    }
</style>
<div class="pageContent">
    <form enctype="multipart/form-data" id="pagerForm" method="post" action="<c:url value='/news/addNews'/>" class="pageForm required-validate"
          onsubmit="return iframeCallback(this,callbackForSubmit)" rel="dlg_sys_user_edit" >
        <div class="pageFormContent" style="height:400px">
            <p class="fix_p">
                <label for="txt_news_title" class="required">新闻标题</label>
                <input id="txt_news_title" type="text" name="title" class="required"  value="${news.title }"/>
            </p>
            <p class="fix_p">
                <label for="txt_news_author" class="required">新闻作者</label>
                <input id="txt_news_author" type="text" name="author" class="required"  value="${news.author }"/>
            </p>
            
            <p class="fix_p">
                <label for="txt_news_channel">推送栏目</label>
                <select id="txt_news_channel" name="channelId" class="combox">
                	<c:forEach var="channel" items="${channels}">
	                	<c:choose>
	                		<c:when test="${channel.id == news.channelId }">
	                			<option selected="selected" value="${channel.id}">${channel.title}</option>
	                		</c:when>
	                		<c:otherwise>
	                			<option value="${channel.id}">${channel.title}</option>
	                		</c:otherwise>
	                	</c:choose>
                	</c:forEach>
                </select>
            </p>
            <p class="fix_p">
                <label for="txt_news_type">新闻类型</label>
                <select id="txt_news_type" name="imgNews" class="combox">
	                <c:choose>
	                	<c:when test="${news.imgNews == 1 }">
	                		<option value="0">封面新闻</option>
		                    <option value="1" selected="selected">头条新闻</option>
	                	</c:when>
	                	<c:otherwise>
		                    <option value="0" selected="selected">封面新闻</option>
		                    <option value="1">头条新闻</option>
	                	</c:otherwise>
	                </c:choose>
                </select>
            </p>
            <div>
                <label for="txt_news_img">新闻封面</label>
                <c:choose>
                	<c:when test="${empty news.imgUrl }">
                		<span><input id="txt_news_img" class="required" type="file" name="photo" /></span>
                	</c:when>
                	<c:otherwise>
                		<span id="changeImg"><img id="newsPic" src="${news.imgUrl }" width="200" height="200" align="top"><a href="javascript:changeImg(1);">修改</a></span>
                	</c:otherwise>
	            </c:choose>
            </div>
            <p class="fix_p">
                <label for="txt_news_summary">新闻概述</label>
                <textarea id="txt_news_summary" name="summary" cols="90" rows="2">${news.summary }</textarea>
            </p>
            <p class="fix_p" style="padding-left:25px;">
				<textarea  class="editor required" tools="simple" name="content" cols="90" rows="25"  alt="" uplinkurl="editorUpload" uplinkext="zip,rar,txt" upimgurl="<c:url value='/news/editorUpload'/>" upimgext="jpg,jpeg,gif,png" upflashurl="editorUpload" upflashext="swf" ><p></p>${news.content }</textarea>
            </p>
        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit">提交</button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">取消</button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        <input type="hidden" name="isAddNews" value="${isAddNews}">
        <input type="hidden" name="id" value="${news.id}">
    </form>
</div>
<script type="text/javascript">
function callbackForSubmit(resp, st, xhr) {
    if (resp && resp.succ) {
        alertMsg.info(resp.msg);
        $.pdialog.closeCurrent();
        navTab.reloadFlag("page_news_list");
    } else {
        alertMsg.info(resp.msg + "!");
    }
}
function changeImg(flag){
	if(flag == 1){
		$("#changeImg").html("<input id='txt_news_img' class='required' type='file' name='photo' /><a href='javascript:changeImg(2);'>取消</a>");
	}else{
		$("#changeImg").html("<img id='newsPic' src='${news.imgUrl }' width='200' height='200' align='top'><a href='javascript:changeImg(1);'>修改</a>");
	}
}
</script>